export const flat = (arr) => {
    let res = []
    arr.forEach(item => {
        if (Array.isArray(item)) {
            res.push(flat(item))
        } else {
            res.push(item)
        }
    });
    return res
}

export const reduceFlat = function(arr, depth) {
    return depth > 0 ? arr.reduce((pre, cur) => {
        return pre.concat(Array.isArray(cur) ? reduceFlat(cur, depth - 1) : cur)
    }, []) : arr.slice()
}